class TabledBuilder < ActionView::Helpers::FormBuilder
  
  def self.create_tabled_field(method_name) 
    define_method(method_name) do |field, options, *args|
      label = options[:label] || field.to_s.humanize
      required = options[:required] ? @template.content_tag('span', l('common', 'required'), :class => 'required') : @template.content_tag('span', l('common', 'optional'), :class => 'optional')
      @template.content_tag("tr",
      @template.content_tag("td",
      @template.content_tag("field",
      label + " " + required + ":",
      :for => "#{@object_name}_#{field}"), :class => "tdRight") + 
      @template.content_tag("td", super), :class => "adminForms")
    end
  end
  

  
  (field_helpers - %w(hidden_field)).each do |name|
    create_tabled_field(name)
  end
  
end
